#!/bin/bash
export HOMEDIR=$(dirname $(dirname $(readlink -f "${BASH_SOURCE[0]}")))
source $HOMEDIR/scripts/init-env.sh

echo 是否开始进行数据强一致性检查？该步耗时会很长，输入 y 或 Y,回车确认开始检查，否则退出
p=""
read p
if [ "$p" == "Y" ] || [ "$p" == "y" ]; then
    echo $(date +%F%n%T) "开始进行数据强一致检查"
    echo 程序运行中，详细日志跟踪:  tail -f $HOMEDIR/log/mig-log-$unique_id.log
    $HOMEDIR/workspace/mtk/mtk -c $HOMEDIR/workspace/mtk/mtk-onlydata.json  mvd -p 8 -r ./report/check-data >> $HOMEDIR/log/mig-log-$unique_id.log 2>&1
    awk 'BEGIN { found=0 } /ObjectName Type Summary/ { found=NR } END { if (found > 0) { for (i=found; i<=NR; i++) print lines[i] } } { lines[NR]=$0 }' $HOMEDIR/log/mig-log-$unique_id.log
    echo $(date +%F%n%T) "数据强一致检查完毕，可根据输出的报告路径获取详细核对报告"
else
    echo "用户操作退出"
    exit 1
fi
